import React, { useState } from 'react'
import './TodoHeader.css'
export default function TodoHeader({addTodos}) {
  let [title,setTitle]=useState('')
  return (
    <div className="todo-header">
      <input onKeyUp={e=>{

        if (e.code==='Enter') {
          if (title.trim()!=='') {
            addTodos(title)
          setTitle('')
          }else{
          setTitle('')
        }
          
        }
      }} value={title} onChange={e=>setTitle(e.target.value)} type="text" placeholder="请输入你的任务名称，按回车键确认"/>
    </div>
  )
}
